<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/12/6
 * Time: 9:33
 */

include_once 'dbTools.php';
echo '用户中心';
echo '<br />';
//读取COOKIES

if(!empty($_COOKIE['userKey'])) {
    $userkey = $_COOKIE['userKey'];

//    if($_COOKIE['userid'] !=110 && $_COOKIE['userid'] != 200 && $_COOKIE['userid']!=400){
//        echo 'cookies值异常';die;
//    }
    session_start();
    if (!isset($_SESSION[$userkey])) {
        echo 'cookies值异常';
        die;
    }

    $s_userInfo = $_SESSION[$userkey];
    $userid = $s_userInfo['userid'];
    echo '你的用户编号为: ' . $userid.',登入名： '.$s_userInfo['uesrname'];
    //根据$userid查询用户名
    $userInfo = getUserNameAndPasswordByUserId($userid);
    if ($userkey === md5($userInfo[0].$userInfo[1])) {
        echo '<br />';
        echo '<a href="logout.php">退出登入</a>';
        echo '<br />';
        echo '<a href="../order/order.php">订单中心</a>';
        die;
    }

}
echo '你尚未登入，请登入';
echo '<a href="login.php">请登入</a>';


